import * as fns from '@/utils/stateManage';
import {
	array
} from '@/lib/utils/validate';
/**
	* 给id字段添加一个名称
	* @param {数组或字符串} fields 
	*/
Array.prototype.addName = function (fields) {
	if (array(this)) {
		if (array(fields)) {
			this.forEach(k => {
				fields.forEach(i => {
					try {
						if (fns[i]) k[`${i}_name`] = fns[i](k[i]).name;
					} catch (error) {
					}
				});
			});
		} else {
			this.forEach(k => {
				try {
					if (fns[fields]) k[`${fields}_name`] = fns[fields](k[fields]).name;
				} catch (error) {
				}
			});
		}
	}
}